﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;

namespace DuToanT2.Models.Mapping
{
    public class DinhMuc_ThanhPhanHPMap : EntityTypeConfiguration<DinhMuc_ThanhPhanHP>
    {
        public DinhMuc_ThanhPhanHPMap()
        { 
            // key
            HasKey(t => t.ID);

            // properties
            Property(t => t.ID);

            // table
            ToTable("DinhMuc_ThanhPhanHP");

            // relationship
            HasRequired(t => t.DinhMuc_CongViec)
                .WithMany(c => c.DinhMuc_ThanhPhanHPs)
                .HasForeignKey(t => t.DinhMuc_CongViecId)
                .WillCascadeOnDelete(true);
            HasRequired(t => t.VatTu)
                .WithMany(c => c.DinhMuc_ThanhPhanHPs)
                .HasForeignKey(t => t.VatTuId)
                .WillCascadeOnDelete(true);
        }
    }
}
